]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
notifications: Introduce MessageList.Source object
authorJulian Sparber <julian@sparber.net>
Fri, 26 Jan 2024 10:05:46 +0000 (11:05 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 30 Jan 2024 17:05:23 +0000 (17:05 +0000)
This object contains only the `title` and `icon` of a
`MessageTray.Source` which allows using it for sources
that aren't notification sources like mpris.

The old `MessageTray.Source` isn't renamed to something
less generic to not break API. Once we have a good reason
we should rename it to something more specific.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3103>

js/ui/messageList.js
js/ui/messageTray.js

index d4967ebf6c78a4414eedc9099bfef7dc6a61f32c..2ecea49652a51441fbf3f9424afd802c0e52d224 100644 (file)
@@ -306,6 +306,34 @@ const LabelExpanderLayout = GObject.registerClass({
     }
 });
 
+export const Source = GObject.registerClass({
+    Properties: {
+        'title': GObject.ParamSpec.string(
+            'title', 'title', 'title',
+            GObject.ParamFlags.READWRITE,
+            null),
+        'icon': GObject.ParamSpec.object(
+            'icon', 'icon', 'icon',
+            GObject.ParamFlags.READWRITE,
+            Gio.Icon),
+        'icon-name': GObject.ParamSpec.string(
+            'icon-name', 'icon-name', 'icon-name',
+            GObject.ParamFlags.READWRITE,
+            null),
+    },
+}, class Source extends GObject.Object {
+    get iconName() {
+        if (this.gicon instanceof Gio.ThemedIcon)
+            return this.gicon.iconName;
+        else
+            return null;
+    }
+
+    set iconName(iconName) {
+        this.icon = new Gio.ThemedIcon({name: iconName});
+    }
+});
+
 const TimeLabel = GObject.registerClass(
 class TimeLabel extends St.Label {
     _init() {
index bd8be9b29c81a9cfb6bb1e07e4f98aa42827e128..7427b4a51ef23082cf06766a506ffa3960de6e4f 100644 (file)
@@ -12,6 +12,7 @@ import * as Calendar from './calendar.js';
 import * as GnomeSession from '../misc/gnomeSession.js';
 import * as Layout from './layout.js';
 import * as Main from './main.js';
+import * as MessageList from './messageList.js';
 import * as Params from '../misc/params.js';
 import * as SignalTracker from '../misc/signalTracker.js';
 
@@ -590,25 +591,13 @@ export const Source = GObject.registerClass({
             'policy', 'policy', 'policy',
             GObject.ParamFlags.READWRITE,
             NotificationPolicy.$gtype),
-        'title': GObject.ParamSpec.string(
-            'title', 'title', 'title',
-            GObject.ParamFlags.READWRITE,
-            null),
-        'icon': GObject.ParamSpec.object(
-            'icon', 'icon', 'icon',
-            GObject.ParamFlags.READWRITE,
-            Gio.Icon),
-        'icon-name': GObject.ParamSpec.string(
-            'icon-name', 'icon-name', 'icon-name',
-            GObject.ParamFlags.READWRITE,
-            null),
     },
     Signals: {
         'destroy': {param_types: [GObject.TYPE_UINT]},
         'notification-added': {param_types: [Notification.$gtype]},
         'notification-show': {param_types: [Notification.$gtype]},
     },
-}, class Source extends GObject.Object {
+}, class Source extends MessageList.Source {
     constructor(params) {
         super(params);
 
@@ -657,17 +646,6 @@ export const Source = GObject.registerClass({
         return new NotificationBanner(notification);
     }
 
-    get iconName() {
-        if (this.gicon instanceof Gio.ThemedIcon)
-            return this.gicon.iconName;
-        else
-            return null;
-    }
-
-    set iconName(iconName) {
-        this.icon = new Gio.ThemedIcon({name: iconName});
-    }
-
     _onNotificationDestroy(notification) {
         let index = this.notifications.indexOf(notification);
         if (index < 0)